package cn.knightzz.controller;

import cn.knightzz.entity.JsonResult;
import cn.knightzz.mapper.SysEventMapper;
import cn.knightzz.mapper.SysExamineMapper;
import cn.knightzz.vo.IndexEventVO;
import cn.knightzz.vo.IndexMemberVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class SysIndexController {

    @Resource
    SysExamineMapper examineMapper;

    @Resource
    SysEventMapper eventMapper;

    @GetMapping("/index/events/finish")
    public JsonResult<List<IndexEventVO>> getFinishedEvent(){
        List<IndexEventVO> data = eventMapper.selectEventCountByIndex();
        JsonResult<List<IndexEventVO>> result = new JsonResult<>("200", "查询成功!");
        result.setData(data);
        return  result;
    }

    @GetMapping("/index/events/status")
    public JsonResult<List<IndexEventVO>> getEventStatus(){
        List<IndexEventVO> data = eventMapper.selectEventStatusByIndex();
        JsonResult<List<IndexEventVO>> result = new JsonResult<>("200", "查询成功!");
        result.setData(data);
        return  result;
    }

    @GetMapping("/index/members/score")
    public JsonResult<List<IndexMemberVO>> getMemberScore(){
        List<IndexMemberVO> data = examineMapper.getMemberScoreByIndex();
        JsonResult<List<IndexMemberVO>> result = new JsonResult<>("200", "查询成功!");
        result.setData(data);
        return  result;
    }
}
